/**
* Copyright (C) 2013-2015
*
* @file   S_3_Function_doAction.c
*
* @remark
*
*/

#include "S_3_Function_doAction.h"
#include "iid.h"

#include "gwin_main_task.h"


static operation_code_t A_3_3_Action(uint32_t in_actionType)
{
    // TODO: 在这里执行真正的Action操作
    uint8_t action = 0;
    switch (in_actionType)
    {
        case 1:
            action = MAIN_TASK_MSG_EX_ACT_SUBTYPE_CALIBRATION;
            break;
        case 2:
            action = MAIN_TASK_MSG_EX_ACT_SUBTYPE_REMOTE_PAIR_START;
            break;
        case 3:
            action = MAIN_TASK_MSG_EX_ACT_SUBTYPE_REMOTE_PAIR_CLEAR;
            break;
    }
    if (action > 0)
    {
        gwin_main_extern_action(action);
    }

    return OPERATION_OK;
}

/**
 * 将Action调用转换为强类型的函数调用。
 */
static void A_3_3_Action_doInvoke(action_operation_t *o)
{
    // 检查输入参数个数
#if 0
    if (o->in->size != 1)
    {
        o->code = OPERATION_INVALID;
        return;
    }
#endif
    // 输出结果个数
    o->out->size = 0;

    // 调用真正的执行函数
    o->code = A_3_3_Action(o->in->arguments[0].value->data.number.ulongValue);
}

void S_3_Function_doAction(action_operation_t *o)
{
    switch (o->aiid)
    {
        case IID_3_3_Action:
            A_3_3_Action_doInvoke(o);
            break;

        default:
            o->code = OPERATION_INVALID;
            break;
    }
}
